home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_pow_railcharges_m.cog < prev    next >
Text File  |  1998-02-25  |  4KB  |  169 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # POW_RAILCHARGES_M.COG
  4. #
  5. # POWERUP Script - Rail Charges
  6. #
  7. # [YB & CYW] + [RF]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. thing       powerup                          local
  15. thing       player                           local
  16. thing       sender                           local
  17. flex        damage                           local
  18. int         bin=15                           local
  19. sound       pickupsnd=helthpu1.wav           local
  20. sound       respawnsnd=Activate01.wav        local
  21. flex        amount                           local
  22.  
  23. template    sparkTemplate=+sparks            local
  24. int         scratch                          local
  25.  
  26. sound       fireSound=RailChargeFire01.WAV   local
  27. template    projectile=+sraildet             local
  28. template    blast=+small_exp                 local
  29.  
  30. vector      thingPos                         local
  31. vector      randVec                          local
  32.  
  33. int         bin_contents=0                   local
  34.  
  35. message     timer
  36. message     created
  37. message     damaged
  38. message     touched
  39. message     taken
  40. message     respawn
  41.  
  42. end
  43.  
  44. # ========================================================================================
  45.  
  46. code
  47.  
  48. created:
  49.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  50.    Return;
  51.  
  52. # ............................................................................................
  53.  
  54. touched:
  55.    player = GetSourceRef();
  56.  
  57.    if (GetInv(player, bin) < GetInvMax(player, bin))
  58.    {
  59.       TakeItem(GetSenderRef(), -1);
  60.       call taken;
  61.    }
  62.  
  63.    Return;
  64.  
  65. # ........................................................................................
  66.  
  67. damaged:
  68.    damage = GetParam (0);
  69.    sender = GetSenderRef();
  70.  
  71.       // If it's already dead, don't allow any more damage.
  72.    if ((GetThingUserData (sender) == 0.0) || (rand() < 0.5))
  73.       return;
  74.  
  75.    // see if this will cause the explosion
  76.    if (GetThingUserData (sender) <= damage)
  77.    {
  78.       SetThingUserData(sender, 0.0);
  79.  
  80.       CreateThingNR(sparkTemplate, sparkSpot);
  81.  
  82.       SetTimerEx(0.5, 2, sender, 0);
  83.    }
  84.    else
  85.    {
  86.       SetThingUserData(sender, GetThingUserData (sender) - damage);
  87.    }
  88.  
  89.    ReturnEx (0);
  90.    return;
  91.  
  92. # ........................................................................................
  93.  
  94. taken:
  95.    player = GetSourceRef();
  96.    powerup = GetSenderRef();
  97.  
  98.       // If the object has been destroyed, don't award it to the player.
  99. //   if (GetThingUserData (sender) == 0.0)
  100. //    return;
  101.  
  102.    // Print("Rail Charges");
  103.    jkPrintUNIString(player, bin);
  104.  
  105.    // Do effects.
  106.    PlaySoundLocal(pickupsnd, 1, 0, 0);
  107.    AddDynamicTint(player, 0.0, 0.0, 0.2);
  108.  
  109.    // store the old bin contents
  110.    bin_contents = GetInv(player, bin);
  111.  
  112.    // Increment powerup amount.
  113.    ChangeInv(player, bin, 3.0);
  114.  
  115.    // Check for Auto Reload
  116.    if(GetAutoReload() & 1)
  117.    {
  118.       if(!bin_contents)
  119.       {
  120.          if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  121.          {
  122.             // Try to autoselect and see if the best weapon is the railgun
  123.             if(AutoSelectWeapon(player, 2) == 7) SelectWeapon(player, 7);
  124.          }
  125.       }
  126.    }
  127.  
  128.    Return;
  129.  
  130. # ........................................................................................
  131.  
  132. respawn:
  133.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  134.    PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
  135.  
  136.    Return;
  137.  
  138. # ........................................................................................
  139.  
  140. timer:
  141.    sender = GetParam(0);
  142.  
  143.    if (GetSenderID() == 1)
  144.    {
  145.       thingPos = GetThingPos(sender);
  146.  
  147.       scratch = GetParam(1);
  148.  
  149.       while (scratch > 0)
  150.       {
  151.          randVec = VectorSet(rand() * 20, rand() * 360, 0);
  152.          CreateThingAtPosNR(projectile, GetThingSector(sender), thingPos, randVec);
  153.  
  154.          scratch = scratch - 1;
  155.       }
  156.  
  157.       TakeItem(sender, -1);
  158.    }
  159.    else
  160.    if (GetSenderID() == 2)
  161.    {
  162.       SetTimerEx(0.5, 1, sender, 2);
  163.  
  164.       CreateThingNR(blast, sender);
  165.    }
  166.    return;
  167. end
  168.  
  169.